<?php $this->_extends('_layouts/bocib_layout'); ?>

<?php $this->_block('content');?>
<div id="content">
    <h2>添加文章分类</h2>
    <p class="stips pdl40">小提示：不可删除有新闻的分类</p>
    <p class="stips pdl40">若要删除，请先将所属该分类的新闻删除或更改至其他分类</p>
    <hr />
    <div id="ctgryList">
        <?php foreach(NewsCategory::find('parent_id = 0')->all()->query() as $lv1Ctgry) { ?>
        <ul>
            <li>
                <?=$lv1Ctgry->category;?>
                <a href="<?=url('bonewsnotice/editnewsctgry', array('id'=>$lv1Ctgry->id));?>">(更新)</a>
                <a href="<?=url('bonewsnotice/deletenewsctgry', array('id'=>$lv1Ctgry->id));?>">(删除)</a>
                <ul>
                    <?php foreach(NewsCategory::find('parent_id = ?', $lv1Ctgry->id)->all()->query() as $key => $lv2Ctgry) { ?>
                    <li>
                    <?=$key+1;?>. <?=$lv2Ctgry->category;?>
                    <a href="<?=url('bonewsnotice/editnewsCtgry', array('id'=>$lv2Ctgry->id));?>">(更新)</a>
                    <a href="<?=url('boNewsnotice/deletenewsCtgry', array('id'=>$lv2Ctgry->id));?>">(删除)</a>
                        <ul>
                            <?php foreach(NewsCategory::find('parent_id = ?', $lv2Ctgry->id)->all()->query() as $key => $lv3Ctgry) { ?>
                            <li>
                            <?=$key+1;?>. <?=$lv3Ctgry->category;?>
                            <a href="<?=url('bonewsnotice/editnewsCtgry', array('id'=>$lv3Ctgry->id));?>">(更新)</a>
                            <a href="<?=url('boNewsnotice/deletenewsCtgry', array('id'=>$lv3Ctgry->id));?>">(删除)</a>
                            </li>
                        <?php } ?>
                        </ul>
                    </li>
                <?php } ?>
                </ul>
            </li>
        </ul>
        <?php } ?>
    </div>

    <div id="ctgryAdd">
        <form action="<?=url('bonewsnotice/addnewsctgry');?>" method="post">
            <div>
                <label>新分类名称:</label>
                <input type="text" name="new_ctgry" value="" /><br />
                <label>父分类名称:</label>
                <select name="parent_id">
                    <?php foreach(NewsCategory::find('haschild = 1')->all()->query() as $newsCtgry) { ?>
                    <option value="<?=$newsCtgry->id;?>"><?=$newsCtgry->category;?></option>
                    <?php } ?>
				</select>
				<br />
				<label>是否有子分类:</label>
                <select name="haschild" >
                    <option value="0">否</option>
                    <option value="1">是</option>
                </select>
				<br />
                <input type="submit" value="添加" />
            </div>
        </form>
    </div>
</div>
<?php $this->_endblock('content');?>